<!DOCTYPE html>
<html lang="en">
{# 使用静态文件路经，需要导入静态文件夹 #}
{% load static %}
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>ajax异步提交</title>
{# 导入jquery 库#}
<script src="{% static 'js/jquery-1.12.1.min.js' %}"></script>
</head>
<body>
    <h1>这里是首页ajax</h1><br />
    <label>用户名</label> <input id='username' type="text" /><br />

    <input type="button" value="点击提交" onclick="test_click()"/>
    <script>

        //定义方法
        function test_click(){

            //发送getqingqiu
            //$.getJSON('/d7_json/'+$("#username").val(),function(data){
                // alert(data.name)

            //});
            //发送post请求
            $.post('/d7_json/123',{'name':"你好我是post"},function(data){
                alert(data.name);
            },'json');
            
        }
    </script>
</body>
</html>